package jmotioncapture.geometry2D;

/**
 * A point representing a location in (x, y) coordinate space, specified in
 * short precision. Point(0,0) represent the top-right point. <br>
 * Each point also included a <b>Identifier</b> and <b>static count</b>.
 * <li>This identifier is represented in <code>short</code>.If no value is
 * set it will default to -1.</li>
 * 
 * <li><code>staticCount</code> is used to measure the weighting of how the
 * point is static compare with the last point. If no value is set it will
 * default to -1.</li>
 * <b>The calculation of this weighting is still not implemented.</b><br>
 * 
 * @author Kenneth Lo
 * @since 1.0.0
 * 
 */
public class Point {

	/**
	 * The x coordinate. If no x coordinate is set it will default to 0.
	 * 
	 * @since 1.0.0
	 */
	private short x = 0;

	/**
	 * The y coordinate. If no y coordinate is set it will default to 0.
	 * 
	 * @since 1.0.0
	 */
	private short y = 0;

	/**
	 * Identifier of the point. If no value is set it will default to -1.
	 * 
	 * @since 1.0.0
	 */
	private short id = -1;

	/**
	 * The weighting that defined the point is static or dynamic. If no value is
	 * set it will default to -1.
	 * 
	 * @since 1.0.0
	 */
	private double staticCount = -1;

	/**
	 * Point refer the prev Point.
	 * 
	 * @since 1.0.0
	 */
	private Point prevPoint;

	/**
	 * Point refer to the next Point.
	 * 
	 * @since 1.0.0
	 */
	private Point nextPoint;

	/**
	 * Constructs and initializes a point at the specified (x, y) location in
	 * the coordinate space.
	 * 
	 * @param x
	 *            the x coordinate
	 * @param y
	 *            the y coordinate
	 * @since 1.0.0
	 */
	public Point(short x, short y) {
		this.x = x;
		this.y = y;
		this.staticCount = -1;
	}

	/**
	 * Constructs and initializes a point at the specified (x, y) location in
	 * the coordinate space.
	 * 
	 * @param x
	 *            the x coordinate
	 * @param y
	 *            the y coordinate
	 * @param id
	 *            identifer of the point
	 * @since 1.0.0
	 */
	public Point(short x, short y, short id) {
		this.x = x;
		this.y = y;
		this.id = id;
		this.staticCount = -1;
	}

	/**
	 * Constructs and initializes a point at the specified (x, y) location in
	 * the coordinate space.
	 * 
	 * @param x
	 *            the x coordinate
	 * @param y
	 *            the y coordinate
	 * @param staticCount
	 *            weighting of how static the point is
	 * @since 1.0.0
	 * 
	 */
	public Point(short x, short y, double staticCount) {
		this.x = x;
		this.y = y;
		this.staticCount = staticCount;
	}

	/**
	 * Constructs and initializes a point at the specified (x, y) location in
	 * the coordinate space.
	 * 
	 * @param x
	 *            the x coordinate
	 * @param y
	 *            the y coordinate
	 * @param id
	 *            identifer of the point
	 * @param staticCount
	 *            weighting of how static the point is
	 * @since 1.0.0
	 * 
	 */
	public Point(short x, short y, short id, double staticCount) {
		this.x = x;
		this.y = y;
		this.id = id;
		this.staticCount = staticCount;
	}

	/**
	 * Get the id of the point.
	 * 
	 * @return identifer of the point, return -1 is no ID is set.
	 * @since 1.0.0
	 */
	public short getID() {
		return id;
	}

	/**
	 * Get the x-coordinate.
	 * 
	 * @return the X coordinate of the point in <code>short</code> precision
	 * @since 1.0.0
	 */
	public short getX() {
		return this.x;
	}

	/**
	 * Get the y-coordinate.
	 * 
	 * @return the Y coordinate of the point in <code>short</code> precision
	 * @since 1.0.0
	 */
	public short getY() {
		return this.y;
	}

	/**
	 * Set the x-coordinate.
	 * 
	 * @since 1.0.0
	 * 
	 */
	public void setX(short x) {
		this.x = x;
	}

	/**
	 * Set the y-coordinate.
	 * 
	 * @since 1.0.0
	 */
	public void setY(short y) {
		this.y = y;
	}

	/**
	 * Set the staticCount.
	 * 
	 * @since 1.0.0
	 */
	public void setStaticCount(double staticCount) {
		this.staticCount = staticCount;
	}

	/**
	 * Get the static count value.
	 * 
	 * @return the weighting of how static the point is in double precision
	 * @since 1.0.0
	 */
	public double getStaticCount() {
		return this.staticCount;
	}

	/**
	 * Set the reference of the prev point
	 * 
	 * @param pt
	 *            prev Point
	 * @since 1.0.0
	 */
	public void setPrevPoint(Point pt) {
		this.prevPoint = pt;
	}

	/**
	 * Get the reference of the prev point
	 * 
	 * @return the reference of the prev point
	 * @since 1.0.0
	 */
	public Point getPrevPoint() {
		return this.prevPoint;
	}

	/**
	 * Set the reference of the next point
	 * 
	 * @param pt
	 *            next Point
	 * @since 1.0.0
	 */
	public void setNextPoint(Point pt) {
		this.nextPoint = pt;
	}

	/**
	 * Get the reference of the next point
	 * 
	 * @return the reference of the next point
	 * @since 1.0.0
	 */
	public Point getNextPoint() {
		return this.nextPoint;
	}

	/**
	 * Returns a <code>String</code> representing this <code>Point</code>
	 * and its values.
	 * 
	 * @return a <code>String</code> representing this <code>Point</code>
	 *         object's coordinate. Example (10,20).
	 * @since 1.0.0
	 */
	@Override
	public String toString() {
		return ("(" + x + "," + y + ")");
	}
}
